#include<iostream>
#include<string>
#include<queue>
#define Maxsize 100
using namespace std;
typedef struct node{
	char data;
	struct node *lchild;
	struct node *rchild;
}BTNode;
typedef struct node *BTree;
BTree CreateBTree(string str,int i);
void LeveOrder(BTree b);
int main()
{
	string str;
	cin>>str;
	int i=1;
	BTree BT;
	BT=CreateBTree(str,i);
	LeveOrder(BT);
	return 0;	
}
BTree CreateBTree(string str,int i)
{
    BTree BT;
	BT = new BTNode;
	if(str[i]=='#')
	return NULL;
	if(i>str.size()-1||i<0)
	return NULL;
	BT->data=str[i];
	BT->lchild=CreateBTree(str,2*i);
	BT->rchild=CreateBTree(str,2*i+1);
   return BT;
}
void LeveOrder(BTree b)
{
	BTree qu[Maxsize],p;
	int front,rear;
	front=rear= -1;
	if(b!=NULL){
		rear++;
		qu[rear]=b;
	}
	else
	cout<<"NULL";
	int flag=0;
	while(front!=rear)
	{
		front=(front+1)%Maxsize;
		p=new BTNode;
		p=qu[front];
		if(flag==1)
		cout<<" "<<p->data;
		if(flag==0)
		cout<<p->data;
		flag=1;
		if(p->lchild!=NULL){
			rear++;
			qu[rear]=p->lchild;
		}
		if(p->rchild!=NULL){
			rear++;
			qu[rear]=p->rchild;
		}
	}	
}


